<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>JSONP 案例</title>
</head>
<body>
<label for="username">用户名：</label>
<input type="text" id="username">
<p id="msg"></p>
<script>
    const username = document.getElementById('username')
    const msg = document.getElementById('msg')

    // 声明handle函数
    function handle(data) {
        username.style.border = '2px solid red'
        msg.innerHTML = data.msg
    }

    username.onblur = function() {
        // 获取用户输入的值
        let name = this.value;
        // 向服务器发送请求 检查用户是否存在
        const script = document.createElement('script')
        script.src = 'http://localhost:8000/check-username'
        document.body.appendChild(script)

    }
</script>
</body>
</html>
